import { getAllArticles, logout, getUserInfo } from '@/apis/modules/article';
import { getToken, setToken, removeToken } from '@/utils/auth';
import { GET_ALL_ARTICLES } from '@/constants/apiTypes';

const article = {
  state: {
    articleList: [],
  },
  mutations: {
    [GET_ALL_ARTICLES](state, data) {
      state.articleList = data;
    }
  },
  actions: {
    [GET_ALL_ARTICLES]({commit}) {
      return getAllArticles().then(res => {
        if (res.success) {
          commit(GET_ALL_ARTICLES, res.data);
        }
        return res;
      });
    }
  }
};

export default article;
